package com.netintech.intelligenceInterface.common.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 *
 * @author lining
 */
@Configuration
public class WebConfigurer implements WebMvcConfigurer {

    @Bean
    public IpInterceptor getIpInterceptor() {
        return new IpInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new InterfaceDemonstrationInterceptor()).addPathPatterns("/test/**");
        //拦截器的添加顺序决定了拦截的顺序
        //频率拦截器
//        registry.addInterceptor(getIpInterceptor()).addPathPatterns("/**").excludePathPatterns("/test/**");
        //鉴权拦截器
        registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**").excludePathPatterns("/test/**");

        //限流拦截器
    }
}
